#region MIT Licence
/*
 * Copyright (C) 2014 PdfCreative
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
 * and associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom 
 * the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included 
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
 * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#endregion

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace PdfCreative.Pdf.Writer.Utilities
{
    /// <summary>
    /// The ImageUtilities class is a static library class that provides convenience methods that deal
    /// with images.
    /// </summary>
    public static class ImageUtilities
    {
        // Public methods
        // ==============
        #region Public methods
        /// <summary>
        /// Retrieves the type of the image contained in the specified file. The type matching is based on filename only, not
        /// on the actual contents of the file stream.
        /// </summary>
        /// <param name="fileInfo">The file to retrieve the image information from.</param>
        /// <returns>The type of image.</returns>
        public static ImageType GetImageType(FileInfo fileInfo)
        {
            if (null == fileInfo) throw new ArgumentNullException("fileInfo");

            ImageType imageType = ImageType.Unknown;

            string extension = Path.GetExtension(fileInfo.FullName);
            switch (extension.ToLower())
            {
                case ".jpeg":
                case ".jpg":
                    imageType = ImageType.Jpeg;
                    break;
            }

            return imageType;
        } // GetImageType()
        #endregion
    }
}
